package com.yun.algorithmproblem.huaweiod;

import java.util.Scanner;

public class OD153 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //String s = in.nextLine();
        String s = "aBB9";
        char[] chars = s.toCharArray();
        int ch = 0;
        boolean hasChar = false;
        int max = -1;
        for (int start = 0, end = 0; end < chars.length; end++) {
            if (!('0' <= chars[end] && chars[end] <= '9')) {//不是数字
                if (hasChar) {
                    if (end - start > max) {
                        max = end - start;
                    }
                    start = ch + 1;
                } else {
                    hasChar = true;
                }
                ch = end;
            }
            if (end == chars.length - 1 && hasChar && end - start + 1 > max) {
                max = end - start + 1;
            }
        }
        if (max == 1) {
            max = -1;
        }
        System.out.println(max);
    }
}
